<script setup lang="ts">
  import { Field } from 'vee-validate';
  import { useLocale } from '@/locales/useLocale';
  const props = withDefaults(
    defineProps<{
      name: string;
      placeholder?: string;
      label?: string;
      checkboxContent?: string;
      requiredField?: boolean;
      size?: 'large' | 'small' | 'default';
      animateClass?: string;
    }>(),
    {
      name: 'default',
      label: '',
      checkboxContent: '',
      requiredField: false,
      size: 'default',
      animateClass: '',
    }
  );
  const { t } = useLocale();
</script>

<template>
  <Field :name="name" v-slot="{ value, field, errorMessage }">
    <el-form-item
      :error="errorMessage && t(errorMessage + '')"
      :label="label && t(label)"
      :class="{ 'field-required': requiredField, [animateClass]: animateClass }"
      :size="size"
    >
      <el-checkbox :model-value="value" v-bind="{ ...field, ...$attrs }">
        <div class="flex-justify-items-center">
          {{ t('message.sys.login.prefixPolicy') }}
          <el-link type="primary" target="_blank" href="/#/useragreement">
            《{{ t('message.sys.login.suffixPolicy') }}》
          </el-link>
        </div>
      </el-checkbox>
    </el-form-item>
  </Field>
</template>

<style lang="scss"></style>
